package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.UserinfoActive;
import com.stylefeng.guns.modular.system.service.IUserinfoActiveService;

/**
 * 用户活跃表控制器
 *
 * @author fengshuonan
 * @Date 2018-12-19 14:03:54
 */
@Controller
@RequestMapping("/userinfoActive")
public class UserinfoActiveController extends BaseController {

    private String PREFIX = "/system/userinfoActive/";

    @Autowired
    private IUserinfoActiveService userinfoActiveService;

    /**
     * 跳转到用户活跃表首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "userinfoActive.html";
    }

    /**
     * 跳转到添加用户活跃表
     */
    @RequestMapping("/userinfoActive_add")
    public String userinfoActiveAdd() {
        return PREFIX + "userinfoActive_add.html";
    }

    /**
     * 跳转到修改用户活跃表
     */
    @RequestMapping("/userinfoActive_update/{userinfoActiveId}")
    public String userinfoActiveUpdate(@PathVariable Integer userinfoActiveId, Model model) {
        UserinfoActive userinfoActive = userinfoActiveService.selectById(userinfoActiveId);
        model.addAttribute("item",userinfoActive);
        LogObjectHolder.me().set(userinfoActive);
        return PREFIX + "userinfoActive_edit.html";
    }

    /**
     * 获取用户活跃表列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return userinfoActiveService.selectList(null);
    }

    /**
     * 新增用户活跃表
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(UserinfoActive userinfoActive) {
        userinfoActiveService.insert(userinfoActive);
        return SUCCESS_TIP;
    }

    /**
     * 删除用户活跃表
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer userinfoActiveId) {
        userinfoActiveService.deleteById(userinfoActiveId);
        return SUCCESS_TIP;
    }

    /**
     * 修改用户活跃表
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(UserinfoActive userinfoActive) {
        userinfoActiveService.updateById(userinfoActive);
        return SUCCESS_TIP;
    }

    /**
     * 用户活跃表详情
     */
    @RequestMapping(value = "/detail/{userinfoActiveId}")
    @ResponseBody
    public Object detail(@PathVariable("userinfoActiveId") Integer userinfoActiveId) {
        return userinfoActiveService.selectById(userinfoActiveId);
    }
}
